<?php

namespace App\Models;

use App\Models\Field\SalonField;

/**
 * App\Models\IndexSalon
 *
 * @property int $id 自增ID
 * @property string $salon_id 沙龙ID
 * @property string $user_id 用户ID
 * @property string $user_description 用户描述
 * @property string $cover_url 封面图地址
 * @property string $title 标题
 * @property string $address 地址
 * @property string $lng 经度
 * @property string $lat 维度
 * @property int $is_deleted 删除状态，0正常，1删除
 * @property int $is_enable 是否启用，0禁用，1启用
 * @property int $is_review 是否为往期回顾，0否，1是
 * @property int $start_at 开始时间戳
 * @property int $end_at 结束时间戳
 * @property int $created_at 创建时间戳
 * @property int $updated_at 更新时间戳
 *
 * @method static \Illuminate\Database\Eloquent\Builder|IndexComment newModelQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|IndexComment newQuery()
 * @method static \Illuminate\Database\Eloquent\Builder|IndexComment query()
 *
 * @property IndexSalon $indexSalon
 * @property SysSalonContent $salonContent
 */
class SysSalon extends BaseModel
{

    protected $table = "sys_salon_";
    protected $primaryKey = "id";
    protected $keyType = "int";
    public $timestamps = true;

    protected $fillable = [];

    protected $hidden = [];

    protected $casts = [
        'created_at' => 'timestamp',
        'updated_at' => 'timestamp',
    ];

    public $fields = [];

    public function indexSalon()
    {
        return $this->hasOne(IndexSalon::class, 'salon_id', 'salon_id');
    }

    public function salonContent()
    {
        return $this->hasOne(SysSalonContent::class, 'salon_id', 'salon_id', $this->salon_id);
    }

    public function commonFormat($scene = SalonField::BASE_INFO): array
    {
        $formats = SalonField::getFormats($scene);
        return SalonField::format($this, $formats);
    }
}
